#include <stdio.h>
#include <string.h>
char s1[1000],s2[1000];
int found_len = 1;
char *findsub(char *longstr, char *substr){
    char tmp = substr[found_len];
    substr[found_len] = '\0';
    char *found = strstr(longstr,substr);
    substr[found_len] = tmp;
    return found;
}
int main(){
    scanf("%s%s",s1,s2);
    int l1 = strlen(s1), l2 = strlen(s2);
    char *shortstr = s2, *longstr = s1;
    int shortlen = l2, longlen = l1;
    if (l2>l1) {
        shortstr = s1;
        longstr = s2;
        shortlen = l1;
        longlen = l2;
    }
    for (char *s = shortstr,*s_end=shortstr+shortlen; s<s_end; s++) {
        char *found = findsub(longstr,s);
        while (found && found_len<shortlen) {
            longstr[longlen+found_len-1]=longstr[found_len-1];
            s_end[found_len-1]=shortstr[found_len-1];
            while (found[found_len]==s[found_len] && found_len<shortlen) {
                longstr[longlen+found_len]=longstr[found_len];
                s_end[found_len]=shortstr[found_len];
                found_len++;
            }
            if (found_len == shortlen) break;
            found_len++;
            found = findsub(found+found_len-1,s);
        }
        if (found) break;
    }
    printf("%d\n",found_len-1);
    return 0;
}